//
//  YCRecruitCell.m
//  YCSchool
//
//  Created by gmall on 16/5/24.
//  Copyright © 2016年 yanglinxia. All rights reserved.
//

#import "YCRecruitCell.h"


@interface YCRecruitCell()
@property (nonatomic,strong) NSDictionary *info;
@end

@implementation YCRecruitCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(nullable NSString *)reuseIdentifier DataSource:(NSDictionary *)info
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.info = info;
        
        CGFloat IPHONE_HEIGHT = [UIScreen mainScreen].bounds.size.height;
        CGFloat IPHONE_WIDTH = [UIScreen mainScreen].bounds.size.width;
        
        //contain
        
        self.backgroundColor = [UIColor yc_colorWithRed:245 Green:245 Blue:245];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.containView = [[UIView alloc] initWithSize:CGSizeMake(IPHONE_WIDTH - 2 * 20, 100)];
        [self.containView setPosition:CGPointMake(IPHONE_WIDTH * 0.5, 120 * 0.5) atAnchorPoint:CGPointMake(0.5, 0.5)];
        self.containView.backgroundColor = [UIColor whiteColor];
        self.containView.layer.cornerRadius = 5;
        [self addSubview:self.containView];
        
        
        //name
        CGFloat itemH = self.containView.yc_height * 0.3;
        
        UILabel *desc = [[UILabel alloc] initWithSize:CGSizeMake(100, itemH)];
        [desc setPosition:CGPointMake(13, 0) atAnchorPoint:CGPointZero];
        [self.containView addSubview:desc];
        desc.text = @"姓名";
        desc.font = [UIFont systemFontOfSize:13];
        [self.containView addSubview:desc];
        desc.textColor = [UIColor yc_colorWithRed:128 Green:128 Blue:128];
        
        self.nameText = [[UILabel alloc] initWithSize:CGSizeMake(self.containView.yc_width - CGRectGetMaxX(desc.frame) - 100, itemH)];
        [self.nameText setPosition:CGPointMake(70,desc.yc_y) atAnchorPoint:CGPointZero];
        [self.containView addSubview:self.nameText];
        self.nameText.textColor = [UIColor yc_colorWithRed:51 Green:51 Blue:51];
        self.nameText.text = @"小明";
        self.nameText.font = [UIFont systemFontOfSize:13];
        
        //time
        self.timeText = [[UILabel alloc] initWithSize:CGSizeMake(100, itemH)];
        [self.timeText setPosition:CGPointMake(self.containView.yc_width - 10, 0) atAnchorPoint:CGPointMake(1, 0)];
        self.timeText.text = @"2个小时前";
        self.timeText.textAlignment = NSTextAlignmentRight;
        [self.containView addSubview:self.timeText];
        self.timeText.font = [UIFont systemFontOfSize:13];
        self.timeText.textColor = [UIColor yc_colorWithRed:51 Green:51 Blue:51];
        
        
        //id
        UILabel *idDesc = [[UILabel alloc] initWithSize:desc.yc_size];
        [idDesc setPosition:CGPointMake(13, itemH) atAnchorPoint:CGPointZero];
        [self.containView addSubview:idDesc];
        idDesc.text = @"身份证";
        idDesc.font = [UIFont systemFontOfSize:13];
        [self.containView addSubview:idDesc];
        idDesc.textColor = [UIColor yc_colorWithRed:128 Green:128 Blue:128];
        
        self.idText = [[UILabel alloc] initWithSize:CGSizeMake(self.containView.yc_width - CGRectGetMaxX(idDesc.frame), itemH)];
        [self.idText setPosition:CGPointMake(70,idDesc.yc_y) atAnchorPoint:CGPointZero];
        [self.containView addSubview:self.idText];
        self.idText.textColor = [UIColor yc_colorWithRed:51 Green:51 Blue:51];
        self.idText.text = @"445222199998989876";
        self.idText.font = [UIFont systemFontOfSize:13];
        
        
        //phone
        UILabel *phoneDesc = [[UILabel alloc] initWithSize:desc.yc_size];
        [phoneDesc setPosition:CGPointMake(13, 2 * itemH) atAnchorPoint:CGPointZero];
        [self.containView addSubview:phoneDesc];
        phoneDesc.text = @"身份证";
        phoneDesc.font = [UIFont systemFontOfSize:13];
        [self.containView addSubview:phoneDesc];
        phoneDesc.textColor = [UIColor yc_colorWithRed:128 Green:128 Blue:128];
        
        self.phoneText = [[UILabel alloc] initWithSize:CGSizeMake(self.containView.yc_width - CGRectGetMaxX(phoneDesc.frame), itemH)];
        [self.phoneText setPosition:CGPointMake(70,phoneDesc.yc_y) atAnchorPoint:CGPointZero];
        [self.containView addSubview:self.phoneText];
        self.phoneText.textColor = [UIColor yc_colorWithRed:51 Green:51 Blue:51];
        self.phoneText.text = @"13729878976";
        self.phoneText.font = [UIFont systemFontOfSize:13];
        
    }
    return self;
}

- (void)setModel:(YCHadRecruitModel *)model
{
    _model = model;
    self.nameText.text = model.ycname;
    self.idText.text = model.ycidcard;
    self.phoneText.text = model.ycmobile;
    self.timeText.text = [NSDate yc_dateStringWithAddTimeString:model.addtime_str formatter:@"yyyy-MM-dd HH:mm:ss"];
}
@end
